<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>客户列表导出 - 管理后台</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            min-height: 100vh;
            background: linear-gradient(135deg, #e0e7ff 0%, #f5f7fa 100%);
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
            color: #333;
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: calc(100vh - 40px);
            max-width: 1200px;
            margin: 0 auto;
        }

        header {
            text-align: center;
            margin-bottom: 40px;
            width: 100%;
        }

        header h1 {
            font-size: 2.5rem;
            color: #1a3a6c;
            margin-bottom: 10px;
        }

        header p {
            font-size: 1.2rem;
            color: #555;
            max-width: 600px;
            margin: 0 auto;
        }

        .dashboard {
            display: flex;
            flex-wrap: wrap;
            gap: 30px;
            width: 100%;
            justify-content: center;
        }

        .card {
            background: #fff;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            padding: 40px;
            width: 100%;
            max-width: 480px;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
        }

        .section-title {
            font-size: 28px;
            color: #1a3a6c;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 3px solid #1a3a6c;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .section-title i {
            color: #007bff;
            font-size: 28px;
        }

        .card-content {
            display: flex;
            flex-direction: column;
        }

        .info-box {
            background: linear-gradient(to right, #f8f9ff, #eef2ff);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 30px;
            border-left: 4px solid #1a3a6c;
        }

        .info-box h3 {
            font-size: 18px;
            color: #1a3a6c;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .info-box p {
            font-size: 15px;
            color: #555;
            line-height: 1.7;
        }

        .btn-primary {
            width: 100%;
            padding: 18px;
            border-radius: 10px;
            font-size: 20px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            background: linear-gradient(to right, #1a3a6c, #2c5282);
            color: #fff;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 15px;
            box-shadow: 0 4px 12px rgba(26, 58, 108, 0.15);
            margin-top: 15px;
        }

        .btn-primary:hover {
            background: linear-gradient(to right, #15315a, #1e436e);
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(26, 58, 108, 0.25);
        }

        .result-card {
            margin-top: 30px;
            background: #f8f9fa;
            border-left: 4px solid #1a3a6c;
            border-radius: 12px;
            padding: 22px 25px;
            font-size: 17px;
            color: #1a3a6c;
            box-shadow: 0 3px 10px rgba(26, 58, 108, 0.08);
            display: none;
            align-items: center;
            gap: 15px;
            transition: all 0.4s ease;
        }

        .result-card.success {
            border-left-color: #2ecc71;
            background: #f0fdf4;
            color: #2ecc71;
        }

        .result-card.error {
            border-left-color: #e74c3c;
            background: #fef2f2;
            color: #e74c3c;
        }

        .result-card i {
            font-size: 22px;
        }

        .stats-card .section-title {
            color: white;
            border-color: rgba(255, 255, 255, 0.3);
        }

        .stats-card .section-title i {
            color: #a3c4ff;
        }

        footer {
            margin-top: 50px;
            text-align: center;
            width: 100%;
            color: #666;
            padding: 20px 0;
            font-size: 15px;
        }

        @media (max-width: 768px) {
            .dashboard {
                flex-direction: column;
                align-items: center;
            }

            .card {
                max-width: 100%;
            }

            .section-title {
                font-size: 24px;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1><i class="fas fa-users"></i> 客户管理后台</h1>
            <p>高效管理客户信息，导出数据进行进一步分析</p>
        </header>

        <div class="dashboard">
            <div class="card">
                <div class="section-title">
                    <i class="fa fa-file-csv"></i> 客户列表导出
                </div>

                <div class="card-content">
                    <div class="info-box">
                        <h3><i class="fas fa-info-circle"></i> 使用说明</h3>
                        <p>点击下方按钮将导出当前系统中的所有客户数据，数据将以CSV格式下载，可直接在Excel或其他数据分析软件中打开。</p>
                    </div>

                    <button class="btn-primary" onclick="downloadUserCSV()">
                        <i class="fa fa-download"></i> 导出客户CSV数据
                    </button>

                    <div class="result-card" id="user-csv-result">
                        <i class="fa"></i>
                        <span id="user-csv-result-text"></span>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <script>
    function downloadUserCSV() {
        fetch('http://localhost:8080/admin/user/toCSV').then(r => r.blob()).then(blob => {
            const url = window.URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = 'user.csv';
            a.click();
            showCSVResult({code:'200',message:'下载完成'});
        }).catch(e => showCSVResult({code:'error',message:e.toString()}));
    }
    function showCSVResult(d) {
        const card = document.getElementById('user-csv-result');
        const text = document.getElementById('user-csv-result-text');
        if(d.code === '200') {
            card.className = 'result-card success';
            card.querySelector('i').className = 'fa fa-check-circle';
            text.innerText = d.message || '下载完成';
        } else {
            card.className = 'result-card error';
            card.querySelector('i').className = 'fa fa-times-circle';
            text.innerText = d.message || '导出失败';
        }
        card.style.display = 'flex';
    }
    </script>
</body>
</html>